<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/Layout.xhtml">
	<!--    xmlns:c="http://java.sun.com/jsf/jstl/core" -->

	<ui:define name="content">
	
	<f:metadata>
		<f:event type="preRenderView" listener="#{loginController.testeSessaoAdm}"/> 
	</f:metadata>
	
		<p:tabView id="tbv1">
			<p:tab title="Cliente">
				<h:form prependId="false" id="formCliente">
					<p:growl id="msg0" />
					<h:panelGrid columns="2" cellpadding="10" styleClass="panelGrid"
						id="grid0">

						<h:outputLabel />
						<h:inputHidden id="idpessoa" value="#{clienteController.cliente.id_pessoa}" />
							
						<h:outputLabel for="nomeCliente" value="Nome.:" />

						<p:inputText id="nomeCliente" size="40"
							value="#{clienteController.cliente.nome}"
							onkeyup="this.value = this.value.toUpperCase()" required="true"
							requiredMessage="O Campo Nome é Obrigatório!">
						</p:inputText>
						
						<h:outputLabel for="loginCliente" value="login.:" />
						<p:inputText id="loginCliente" size="40"
							value="#{clienteController.cliente.login}"
							required="true"
							requiredMessage="O Campo Login é Obrigatório!">
						</p:inputText>
						
						<h:outputLabel for="senhaCliente" value="Senha.:" />
						<p:password id="senhaCliente" size="40"
							value="#{clienteController.cliente.senha}" match="confirmarSenha"
							required="true"
							requiredMessage="O Campo Senha é Obrigatório!"
							validatorMessage="As senhas devem ser iguais!">
						</p:password>
						
						<h:outputLabel for="confirmarSenha" value="Confirmar Senha.:" />
						<p:password id="confirmarSenha" size="40"
							value="#{clienteController.cliente.senha}"
							required="true"
							requiredMessage="O Campo de confirmação de senha é Obrigatório!">
						</p:password>

						<p:panel>
							<p:commandButton value="Salvar"
								action="#{clienteController.salvar}"
								image="ui-icon ui-icon-disk" update=":tbv1">
							</p:commandButton>

							<p:commandButton value="Cancelar"
								actionListener="#{clienteController.clear}"
								image="ui-icon ui-icon-close" update=":tbv1:formCliente">
							</p:commandButton>
						</p:panel>
					</h:panelGrid>
				</h:form>
			</p:tab>
			
			<p:tab title="Lista de Clientes">
			<h:form id="formClientes">
				<p:dataTable var="cliente" value="#{projetoController.clientePorSM}">
								<p:column headerText="Nome">
									<h:outputText value="#{cliente.nome}" />
								</p:column>
								
								<p:column headerText="Login">
									<h:outputText value="#{cliente.login}" />
								</p:column>
								
								<p:column headerText="Ações">
									
									<p:growl id="grow" showDetail="true" />
									
									<p:commandButton update=":tbv1:dialog"
										icon="ui-icon-pencil" title="View"
										oncomplete="PF('dlgDadosCliente').show();">
										<f:attribute name="clienteSelecionado" value="#{cliente}" />
										<f:setPropertyActionListener value="#{cliente}"
											target="#{clienteController.clienteSelecionado}" />
									</p:commandButton>

									<p:commandButton icon="ui-icon-trash"
										actionListener="#{clienteController.deletar}" update=":tbv1:formClientes">
										<f:attribute name="clienteSelecionado" value="#{cliente}" />
										<p:confirm header="Confirmação"
											message="Deseja realmente excluir este cliente?"
											icon="ui-icon-alert" update="grow"/>

										<p:confirmDialog global="true" showEffect="fade"
											hideEffect="explode">
											<p:commandButton value="Sim" type="button"
												styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
											<p:commandButton value="Não" type="button"
												styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
										</p:confirmDialog>
									</p:commandButton>
								</p:column>
							</p:dataTable>
					</h:form>
					<p:dialog id="dialog" widgetVar="dlgDadosCliente" showEffect="clip"
						hideEffect="clip" modal="true" appendTo="@(body)" width="600"
						height="370">

						<h:form id="formDialog">
							<p:outputPanel id="detail" style="text-align:center;"
								layout="block">

								<h:panelGrid columns="2" cellpadding="5">

									<h:outputText value="Nome: " />
									<p:inputText id="clienteNome"
										value="#{clienteController.clienteSelecionado.nome}" />
										
									<h:outputText value="Login: " />
									<p:inputText id="clienteLogin"
										value="#{clienteController.clienteSelecionado.login}" />


								</h:panelGrid>
								<p:commandButton value="Alterar Dados" image="ui-icon-check"
									action="#{clienteController.atualizarDados}"
									update=":tbv1:formClientes"
									process="@form" />

							</p:outputPanel>
						</h:form>
					</p:dialog>
			</p:tab>
		</p:tabView>

		<!--  <h:form id="formtable">
			<p:growl id="msg1" />
			<p:dataTable id="idtabela" var="pessoa" value="" paginator="true"
				rows="10" emptyMessage="Nenhum regitro encontrado"
				paginatorTemplate=" {{CurrentPageReport}  {FirstPageLink} {PreviousPageLink}
                             {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				rowsPerPageTemplate="5,10,15">
				<f:facet name="header">Lista de Pessoas</f:facet>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Nome" />
					</f:facet>
					<h:outputText value="TESTE" />
				</p:column>

				<p:column>
					<p:commandButton image="ui-icon ui-icon-pencil" process="@this"
						update=":tbv1:formPessoa">
					</p:commandButton>

					<p:commandButton image="ui-icon ui-icon-close" update="@form">
					</p:commandButton>
				</p:column>
			</p:dataTable>

		</h:form>-->
	</ui:define>

</ui:composition>